package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecGroupRole;
import org.ycx.upms.dao.model.SecGroupRoleExample;

import java.util.List;

public interface SecGroupRoleMapper {
    @SelectProvider(type = SecGroupRoleSqlProvider.class, method = "countByExample")
    long countByExample(SecGroupRoleExample example);

    @DeleteProvider(type = SecGroupRoleSqlProvider.class, method = "deleteByExample")
    int deleteByExample(SecGroupRoleExample example);

    @Delete({
            "delete from sec_group_role",
            "where GROUP_ID = #{groupId,jdbcType=INTEGER}",
            "and ROLE_ID = #{roleId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(@Param("groupId") Integer groupId, @Param("roleId") Integer roleId);

    @Insert({
            "insert into sec_group_role (GROUP_ID,ROLE_ID)",
            "values (#{groupId,jdbcType=INTEGER},#{roleId})"
    })
    int insert(SecGroupRole record);

    @InsertProvider(type = SecGroupRoleSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "roleId", before = false, resultType = Integer.class)
    int insertSelective(SecGroupRole record);

    @SelectProvider(type = SecGroupRoleSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "GROUP_ID", property = "groupId", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "ROLE_ID", property = "roleId", jdbcType = JdbcType.INTEGER, id = true)
    })
    List<SecGroupRole> selectByExample(SecGroupRoleExample example);

    @UpdateProvider(type = SecGroupRoleSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecGroupRole record, @Param("example") SecGroupRoleExample example);

    @UpdateProvider(type = SecGroupRoleSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") SecGroupRole record, @Param("example") SecGroupRoleExample example);
}